/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.gui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

import com.metier.ProjetMetier;
import com.metier.UsersMetier;

/**
 *
 * @author top
 */
public class AjouterProjets extends javax.swing.JPanel {
 private String 	valeurSelectionner;

    /**
     * Creates new form AjouterProjets
     */
    public AjouterProjets() {
       // initComponents();
    }
    
    public AjouterProjets(JButton boutonAnnuler) {
        initComponents(boutonAnnuler);
    }

    

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents(JButton buttonAnnuler) {

        jLabel1 = new javax.swing.JLabel();
        textNumero = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        textReference = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        comboEtatProjet = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        textNomClient = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        textUserCreate = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        textDescription = new javax.swing.JTextArea();
        jLabel7 = new javax.swing.JLabel();
        dateDebut = new com.toedter.calendar.JDateChooser();
        jLabel8 = new javax.swing.JLabel();
        dateEcheance = new com.toedter.calendar.JDateChooser();
        jLabel9 = new javax.swing.JLabel();
        dateDeploie = new com.toedter.calendar.JDateChooser();
        jLabel10 = new javax.swing.JLabel();
        dateCreate = new com.toedter.calendar.JDateChooser();
        bontonValider = new javax.swing.JButton();
        boutonAnnuler = new javax.swing.JButton();

        setBackground(new java.awt.Color(128, 130, 133));
        setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(103, 153, 255)));
        setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
        setMaximumSize(new java.awt.Dimension(1056, 410));
        setMinimumSize(new java.awt.Dimension(1056, 410));

        jLabel1.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("Numero :");

        jLabel2.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("Reference :");

        textReference.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textReferenceActionPerformed(evt);
            }
        });

        jLabel3.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
        jLabel3.setForeground(new java.awt.Color(255, 255, 255));
        jLabel3.setText("Etat _Projet");

        comboEtatProjet.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
        comboEtatProjet.setModel(new javax.swing.DefaultComboBoxModel(new String[] {"Etat Projet", "EN Cours", "Fini ", "En Pause" }));
        comboEtatProjet.addActionListener(new ActionListener() {
			
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				Object source = comboEtatProjet.getSelectedItem();
				valeurSelectionner = (String) source;

				
			}
		});

        jLabel4.setBackground(new java.awt.Color(128, 130, 133));
        jLabel4.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
        jLabel4.setForeground(new java.awt.Color(255, 255, 255));
        jLabel4.setText("Nom Client");

        jLabel5.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
        jLabel5.setForeground(new java.awt.Color(255, 255, 255));
        jLabel5.setText("Lead");

        textUserCreate.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N

        jLabel6.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
        jLabel6.setForeground(new java.awt.Color(255, 255, 255));
        jLabel6.setText("Description");

        textDescription.setColumns(20);
        textDescription.setRows(5);
        jScrollPane1.setViewportView(textDescription);

        jLabel7.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
        jLabel7.setForeground(new java.awt.Color(255, 255, 255));
        jLabel7.setText("Date Debut");

        jLabel8.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
        jLabel8.setForeground(new java.awt.Color(255, 255, 255));
        jLabel8.setText("Date Echeance");

        jLabel9.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
        jLabel9.setForeground(new java.awt.Color(255, 255, 255));
        jLabel9.setText("Date Deploie");

        jLabel10.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
        jLabel10.setForeground(new java.awt.Color(255, 255, 255));
        jLabel10.setText("Date Create");

        bontonValider.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
        bontonValider.setText("VALIDER");
        bontonValider.addActionListener(new ActionListener() {
			
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
			
				boolean areEmpty;
				int indexe = -1;
				areEmpty = false;
				if (comboEtatProjet.getSelectedItem().equals("Etat Projet")) {
					indexe = 0;
				}else if (comboEtatProjet.getSelectedItem().equals(
							"En Cours")) {
						indexe = 1;
					
				} else if (comboEtatProjet.getSelectedItem().equals(
						"Fini")) {
					indexe = 2;
				} else if (comboEtatProjet.getSelectedItem().equals("En Pause")) {
					indexe = 3;
				
				} else {
					indexe = -1;
				}
				areEmpty = (!textNomClient.getText().isEmpty()
						&& !textDescription.getText().isEmpty()
						&& !textNumero.getText().isEmpty()
						&& !textReference.getText().isEmpty()
						 && !(indexe == -1)&& !(indexe == 0) );
				if (!areEmpty) {

					JOptionPane.showMessageDialog(bontonValider,
							"veuillez remplir tous les champs");
				} else {
					if (JOptionPane.showConfirmDialog(getFrame(),
							"Voulez-vous vraiment ajouter le projet ?",
							"Information", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
						ProjetMetier projet=new ProjetMetier();
						projet.addProjetsMetier(textDescription.getText(), textReference.getText(), textNumero.getText(), dateEcheance.getDate(), dateDebut.getDate(), dateDeploie.getDate(),valeurSelectionner, textNomClient.getText());
						textDescription.setText("");
						textReference.setText("");
						textNumero.setText("");
						textNomClient.setText("");
						dateCreate.setDate(null);
						dateDebut.setDate(null);
						dateDeploie.setDate(null);
						dateEcheance.setDate(null);
						JOptionPane.showMessageDialog(null, "Le projet a été bien enregistré ");
					}

				
			}
			}
		});

        boutonAnnuler.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
        boutonAnnuler.setText("ANNULER");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE)
                                        .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                    .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(18, 18, 18)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(textUserCreate, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(textNumero)
                                    .addComponent(dateDeploie, javax.swing.GroupLayout.DEFAULT_SIZE, 173, Short.MAX_VALUE))
                                .addComponent(comboEtatProjet, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addComponent(bontonValider))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(dateDebut, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(263, 263, 263)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE)
                            .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(dateCreate, javax.swing.GroupLayout.DEFAULT_SIZE, 185, Short.MAX_VALUE)
                            .addComponent(dateEcheance, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(textNomClient)
                            .addComponent(textReference)
                            .addComponent(jScrollPane1)))
                    .addComponent(buttonAnnuler))
                .addContainerGap(156, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(textNumero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2)
                    .addComponent(textReference, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(textUserCreate)
                            .addComponent(jLabel5)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(textNomClient, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(comboEtatProjet, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addGap(52, 52, 52)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel7)
                                .addComponent(dateDebut, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel8))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(dateEcheance, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(2, 2, 2)))
                        .addGap(30, 30, 30)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabel9)
                                .addComponent(dateDeploie, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel10)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(dateCreate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(2, 2, 2)))
                .addGap(33, 33, 33)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonAnnuler)
                    .addComponent(bontonValider))
                .addContainerGap(79, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

	public JPanel getFrame() {
		return this;
	}

    private void textReferenceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textReferenceActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_textReferenceActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton bontonValider;
    private javax.swing.JButton boutonAnnuler;
    private javax.swing.JComboBox comboEtatProjet;
    private com.toedter.calendar.JDateChooser dateCreate;
    private com.toedter.calendar.JDateChooser dateDebut;
    private com.toedter.calendar.JDateChooser dateDeploie;
    private com.toedter.calendar.JDateChooser dateEcheance;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea textDescription;
    private javax.swing.JTextField textNomClient;
    private javax.swing.JTextField textNumero;
    private javax.swing.JTextField textReference;
    private javax.swing.JTextField textUserCreate;
    // End of variables declaration//GEN-END:variables
	public com.toedter.calendar.JDateChooser getDateCreate() {
		return dateCreate;
	}

	public void setDateCreate(com.toedter.calendar.JDateChooser dateCreate) {
		this.dateCreate = dateCreate;
	}

	public com.toedter.calendar.JDateChooser getDateDebut() {
		return dateDebut;
	}

	public void setDateDebut(com.toedter.calendar.JDateChooser dateDebut) {
		this.dateDebut = dateDebut;
	}

	public com.toedter.calendar.JDateChooser getDateDeploie() {
		return dateDeploie;
	}

	public void setDateDeploie(com.toedter.calendar.JDateChooser dateDeploie) {
		this.dateDeploie = dateDeploie;
	}

	public com.toedter.calendar.JDateChooser getDateEcheance() {
		return dateEcheance;
	}

	public void setDateEcheance(com.toedter.calendar.JDateChooser dateEcheance) {
		this.dateEcheance = dateEcheance;
	}

	public javax.swing.JTextArea getTextDescription() {
		return textDescription;
	}

	public void setTextDescription(javax.swing.JTextArea textDescription) {
		this.textDescription = textDescription;
	}

	public javax.swing.JTextField getTextNomClient() {
		return textNomClient;
	}

	public void setTextNomClient(javax.swing.JTextField textNomClient) {
		this.textNomClient = textNomClient;
	}

	public javax.swing.JTextField getTextNumero() {
		return textNumero;
	}

	public void setTextNumero(javax.swing.JTextField textNumero) {
		this.textNumero = textNumero;
	}

	public javax.swing.JTextField getTextReference() {
		return textReference;
	}

	public void setTextReference(javax.swing.JTextField textReference) {
		this.textReference = textReference;
	}

	public javax.swing.JTextField getTextUserCreate() {
		return textUserCreate;
	}

	public void setTextUserCreate(javax.swing.JTextField textUserCreate) {
		this.textUserCreate = textUserCreate;
	}

	/**
	 * @return the comboEtatProjet
	 */
	public javax.swing.JComboBox getComboEtatProjet() {
		return comboEtatProjet;
	}

	/**
	 * @param comboEtatProjet the comboEtatProjet to set
	 */
	public void setComboEtatProjet(javax.swing.JComboBox comboEtatProjet) {
		this.comboEtatProjet = comboEtatProjet;
	}
	

	
}
